﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace AresCustomYacht.DataContract 
{
    public class Summary
    {

        public int TrackId { get; set; }
        public string Code { get; set; }
        public string Description { get; set; }
        public int DisplayOrder { get; set; }
        
        public int DivisionId { get; set; } // Metal Work
        public string DivisionCode { get; set; }
        public string DivisionName { get; set; }

        public int TradeId { get; set; } // Hull Construction
        public string TradeCode { get; set; }
        public string TradeName { get; set; }

        public int LocationId { get; set; } // Hull appendages
        public string LocationCode { get; set; }
        public string LocationName { get; set; }
       

        public int TaskId { get; set; } //Fabrication
        public string TaskCode { get; set; }
        public string TaskName { get; set; }
        public string TaskDescription { get; set; }

        public string cssClass { get; set; }


        public decimal Percentage
        {
            get
            {
                if (BudgetTotal != 0 )
                    return 100 * ActualTotal / BudgetTotal;
                else
                {
                    return 0;
                }
            }
            
        }

        public decimal BudgetRate { get; set; }
        public decimal InvoiceRate { get; set; }
        public decimal InvoiceMaterialPercentage { get; set; }

        public decimal ActualRate { get; set; }
        
        public decimal BudgetHrs { get; set; }

        public decimal ActualHrs { get; set; }

        public decimal BudgetLabor
        {
            get { return BudgetHrs * BudgetRate; }
        }

        public decimal BudgetMaterial { get; set; }

        private decimal _budgetTotal;
        public decimal BudgetTotal
        {
            get
            {
                if (_actualTotal == 0)
                    return (BudgetRate * BudgetHrs) + BudgetMaterial;
                else
                {
                    return _budgetTotal;
                }
            }

            set { _budgetTotal = value; } //If i set it explicitly it means I need this value. if not then the get should calculate the total
        
        }


        public decimal ActualLabor
        {
            get { return ActualHrs * ActualRate; }
        }

        public decimal ActualMaterial { get; set; }

        private decimal _actualTotal;
        public decimal ActualTotal
        {
            get
            {
                if (_actualTotal == 0)
                    return (ActualRate * ActualHrs) + ActualMaterial;
                else
                {
                    return _actualTotal;
                }
            }
            set { _actualTotal = value; } //If i set it explicitly it means I need this value. if not then the get should calculate the total
        }

        public decimal RemainingLabor
        {
            get { return BudgetLabor - ActualLabor; }
            
        }

        public decimal RemainingMaterial
        {
            get { return BudgetMaterial- ActualMaterial; }

        }


        public decimal RemainingTotal
        {
            get { return BudgetTotal - ActualTotal; }

        }

        public decimal Variance
        {
            get { return 1 - Percentage; }
            
        }
    }
}